﻿using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using ChiakiYu.Core.Domain.Entities;
using ChiakiYu.Model.Roles;

namespace ChiakiYu.Model.Users
{
    /// <summary>
    ///     用户
    /// </summary>
    public class User : FullEntity<long>
    {
        public User()
        {
            Avatar = "avatar_default";
        }

        //[ForeignKey("UserId")]
        public virtual ICollection<Role> Roles { get; set; }

        /// <summary>
        ///     基于用户的权限列表
        /// </summary>
        [ForeignKey("UserId")]
        public virtual ICollection<UserPermission> Permissions { get; set; } //基于用户的权限列表

        #region 持久化属性

        /// <summary>
        ///     用户名
        /// </summary>
        [Required]
        [StringLength(64)]
        public string UserName { get; set; }

        /// <summary>
        ///     密码
        /// </summary>
        [Required]
        [StringLength(256)]
        public string Password { get; set; }

        /// <summary>
        ///     帐号邮箱
        /// </summary>
        [StringLength(64)]
        public string Email { get; set; }

        /// <summary>
        ///     帐号邮箱是否通过验证
        /// </summary>
        public bool EmailConfirmed { get; set; }

        /// <summary>
        ///     手机号码
        /// </summary>
        [StringLength(11)]
        public string Mobile { get; set; }

        /// <summary>
        ///     帐号手机是否通过验证
        /// </summary>
        public bool MobileConfirmed { get; set; }

        /// <summary>
        ///     昵称
        /// </summary>
        [Required]
        [StringLength(64)]
        public string NickName { get; set; }

        /// <summary>
        ///     头像(存储相对路径)
        /// </summary>
        [StringLength(256)]
        public string Avatar { get; set; }

        #endregion
    }
}